package algotithm.acwing.math.test3289;

/**
 * @author 25068
 * @Date 2021/6/27 20:11
 * @Title AcWing 3489. 星期几
 */
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        Map<String,Integer> map = new HashMap<>(1024);
        map.put("January",1);
        map.put("February",2);
        map.put("March",3);
        map.put("April",4);
        map.put("May",5);
        map.put("June",6);
        map.put("July",7);
        map.put("August",8);
        map.put("September",9);
        map.put("October",10);
        map.put("November",11);
        map.put("December",12);
        int[] month = {0,31,28,31,30,31,30,31,31,30,31,30,31};

        while (sc.hasNext()) {
            int d = sc.nextInt();
            String m = sc.next();
            int y = sc.nextInt();
            int day = 0;
            for (int year = 1; year < y; year++) {
                if (isLeap(year)) {
                    day += 366;
                } else {
                    day += 365;
                }
            }
            if (isLeap(y)) {
                month[2] += 1;
            }
            int monthNum = map.get(m);
            for (int mon = 1; mon < monthNum; mon++) {
                day += month[mon];
            }
            day += d;
            // day--;
            day = day % 7;
            String res = dayNum(day);
            System.out.println(res);
            // 记得还原，因为每输入一次闰年数据，表示月份的数组的2月份的值就变化了，因此要记得还原
            if (isLeap(y)) {
                month[2]--;
            }
        }
        //writer.flush();
        //writer.close();
        //reader.close();
    }

    public static boolean isLeap(int y) {
        if (y % 4 == 0 && y % 100 != 0) {
            return true;
        } else if (y % 400 == 0) {
            return true;
        } else {
            return false;
        }
    }

    public static String dayNum(int day) {
        if (day == 1) {
            return "Monday";
        } else if (day == 2) {
            return "Tuesday";
        } else if (day == 3) {
            return "Wednesday";
        } else if (day == 4) {
            return "Thursday";
        } else if (day == 5) {
            return "Friday";
        } else if (day == 6) {
            return "Saturday";
        } else {
            return "Sunday";
        }
    }
}